#include "../hle.h"
#include "../host/host.h"

#include "__sceCtrl.h"

/* Index for the two analog directions */
#define CTRL_ANALOG_X   0
#define CTRL_ANALOG_Y   1

/* Returned control data */
typedef struct
{
    u32 frame;
    u32 buttons;
    u8 lx;
    u8 ly;
    u8 unused[6];
} SceCtrlData;

void sceCtrlSetSamplingMode()
{
    _log(DBG, HLE, "0 = sceCtrlSetSamplingMode(%d)", PARAM(0));
    RETURN(0);
}

void sceCtrlSetSamplingCycle()
{
    _log(DBG, HLE, "0 = sceCtrlSetSamplingCycle(%d)", PARAM(0));
    RETURN(0);
}

void sceCtrlSetIdleCancelThreshold()
{
    _log(DBG, HLE, "0 = sceCtrlSetIdleCancelThreshold(%d, %d)", PARAM(0), PARAM(1));
    RETURN(0);
}

void sceCtrlReadBufferPositive()
{
    SceCtrlData data;
    _log(INF, HLE, "sceCtrlReadBufferPositive(%08x, %d)", PARAM(0), PARAM(1));

    mem_readStruct(PARAM(0), &data, sizeof(SceCtrlData));
    data.frame = 1;
    data.buttons = __sceCtrlGetButtons();
    data.lx = 128;
    data.ly = 128;
    mem_writeStruct(PARAM(0), &data, sizeof(SceCtrlData));
}

void sceCtrlPeekBufferPositive()
{
    SceCtrlData data;
    _log(INF, HLE, "sceCtrlPeekBufferPositive(%08x, %d)", PARAM(0), PARAM(1));

    mem_readStruct(PARAM(0), &data, sizeof(SceCtrlData));
    data.frame = 1;
    data.buttons = __sceCtrlGetButtons();
    data.lx = 128;
    data.ly = 128;
    mem_writeStruct(PARAM(0), &data, sizeof(SceCtrlData));
}


